#include "stdafx.h"
#include "RemoteWeapon.h"


CRemoteWeapon::CRemoteWeapon()
{
}


CRemoteWeapon::~CRemoteWeapon()
{
}

CRemoteWeapon::CRemoteWeapon(IplImage *img[REMOTE_WEAPON_TYPE_COUNT][REMOTE_WEAPON_IMAGE_COUNT], int type, int posx, int posy, int dir, int ap)
{
	for (int i = 0; i < REMOTE_WEAPON_IMAGE_COUNT; i++) {
		m_Img[i] = img[type][i];
	}
	m_MovePos.x = posx, m_MovePos.y = posy;
	m_DrawPos.x = posx * GRID_SIZE, m_DrawPos.y = posy * GRID_SIZE;
	m_Dir = dir;
	m_isClear = false;
	m_StateId = -1;
	m_AP = ap;
}

void CRemoteWeapon::ImageChange()
{
	if (m_Dir == UP) {
		if (m_StateId < 3)	m_StateId++;
		else m_isClear = true;
	}
	else if (m_Dir == DOWN) {
		if (m_StateId == -1) m_StateId = 3;
		if (m_StateId < 7)	m_StateId++;
		else m_isClear = true;
	}
	else if (m_Dir == LEFT) {
		if (m_StateId == -1) m_StateId = 7;
		if (m_StateId < 11)	m_StateId++;
		else m_isClear = true;
	}
	else if (m_Dir == RIGHT) {
		if (m_StateId == -1) m_StateId = 11;
		if (m_StateId < 15)	m_StateId++;
		else m_isClear = true;
	}
}


void CRemoteWeapon::DrawToBack(IplImage *Bg)
{
	int posx = m_MovePos.x * GRID_SIZE;
	int posy = (m_MovePos.y + 1) * GRID_SIZE - m_Img[m_StateId]->height;
	CTools::DrawToBackground(posx, posy, Bg, m_Img[m_StateId], 0, 0, 0);
}

bool CRemoteWeapon::CheckisClear() {
	return m_isClear;
}


void CRemoteWeapon::Move(IplImage * Bg)
{
}
